<template>
	<z-paging v-if="padding_show" :show-refresher-when-reload="false"  show-refresher-update-time  ref="paging" v-model="dataList" @query="queryList">
		<!-- z-paging默认铺满全屏，此时页面所有view都应放在z-paging标签内，否则会被盖住 -->
		<!-- 需要固定在页面顶部的view请通过slot="top"插入，包括自定义的导航栏 -->
		<view slot="top" class="">
			<u-navbar back-text=" " :title="title"></u-navbar>
			<view class="search_box_search">
				<view class="search_input">	
					<input class="input_font" v-model="shopName" placeholder="请输入商城名称" type="text" />
				</view>	
				<image style="width: 64rpx; height: 64rpx;" @click="search" src="https://www.mengkahuyu.com/index_png/search_cion.png" mode=""></image>
			</view>
		</view>
	    <view class="list" >
			<view @click="copy(item.link)" v-for="(item , index) in dataList" class="list_item">
				<view class="list_item_top">
					<span>
						平台名称
					</span>
					<span>
						{{item.name}}
					</span>
				</view>
				<u-image style="width: 100%;" mode="widthFix"  :src="item.pic"></u-image>
				<!-- <view class="" style="margin-bottom: 32rpx;">
					链接地址
				</view>
				<view class="urlClass" style="">
					{{item.link}}
				</view>
				<view class="" style="display: flex; justify-content: flex-end;margin-top: 32rpx;">
					<view @click="copy(item.link)" class="copy_btn">
						复制地址
					</view>
				</view> -->
			</view>
	    </view>
	</z-paging>
</template>

<script>
	export default {
		data() {
			return {
				title:'韩国电商平台',
				padding_show:false,
				kor_type:'',
				shopName:'',// 平台名称 搜索条件
				dataList:[]
			}
		},
		onShow() {
			var token = uni.getStorageSync('token')
			this.kor_type = uni.getStorageSync('kor_type')
			this.padding_show = false
			setTimeout(()=>{
				this.padding_show = true
			},100)
		},
		methods: {
			search(){
				this.$refs.paging.reload()
			},
			copy(url){
				uni.showModal({
					title: '提示',
					content: '复制链接后打开浏览器,浏览商城',
					cancelText: "取消", // 取消按钮的文字  
					confirmText: "复制", // 确认按钮的文字  
					showCancel: true, // 是否显示取消按钮，默认为 true
					success: (res) => {
					if(res.confirm) {  
						uni.setClipboardData({
							data: url,
							success: function(t) {
								uni.showToast({
								    title: '复制成功',
								    //将值设置为 success 或者直接不用写icon这个参数
								    icon: 'success',
								    //显示持续时间为 2秒
								    duration: 2000
								})
							}
						});
					} else {}  
					} 
				})
			},
			queryList(pageNo, pageSize) {
				// 此处请求仅为演示，请替换为自己项目中的请求
				var data = {
					page:pageNo,
					limit:pageSize,
					name:this.shopName
				}
				var token = uni.getStorageSync('token')
				this.$wqzApi.index_link_list(data).then(res=>{
					// console.log(res.data.list)
					this.$refs.paging.complete(res.data.list);
				}).catch(err=>{
					this.$refs.paging.complete(false);
				})
				
			    
			},
		}
	}
</script>

<style lang="scss">
@import url(./index.scss);
</style>
